home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / FAQ.SWG / 0009_BORLAND OVERLAYS QA.pas < prev    next >
Pascal/Delphi Source File  |  1993-06-01  |  3KB  |  76 lines

  1.  
  2.  
  3. TITLE: TRUBO PASCAL OVERLAY ISSUES
  4. ===========================================================
  5.  
  6. TP 5.0 5.5 - OVERLAY SUPPORT
  7. Q. Are overlays supported in 5.0+?
  8. A. Yes! See the example program OVRDEMO.PAS and refer to the
  9.    Turbo Pascal manual for information on overlays.
  10.  
  11. TP 5.0 5.5 - OVERLAY UNITS LOADED INTO BUFFER
  12. Q. Is there any way to determine what overlay units are loaded
  13.    into the overlay buffer?
  14. A. Using Turbo Pascal 5.0+, there is no defined method for
  15.    determining which units are loaded into the overlay buffer
  16.    area. 
  17.  
  18. TP 5.0 5.5 - OVERLAYS *.OVR FILES
  19. Q. How can I transfer a large overlay file onto a floppy disk?
  20. A. If the file does not fit on a single density disk, then
  21.    transfer it to a double density disk.  In the latter case,
  22.    your application will run only from the double density disk or
  23.    a hard disk.
  24.  
  25. TP5.5 OVERLAY
  26. Q. How do I reclaim the memory used by overlay buffer in TP5.5?
  27.  
  28. A. The following example demonstrates how to do so.
  29.  
  30. unit Marker;
  31.  
  32. interface
  33.  
  34. procedure RestoreHeap; procedure RestoreOverlay;
  35.  
  36. implementation
  37.  
  38. var OldHeapPtr,OldHeapOrg,Temp:pointer;
  39.  
  40. var OldHeapPtr,OldHeapOrg,Temp:pointer;
  41.  
  42. procedure RestoreHeap; begin
  43.   Release(Temp);                {2. Release all dynamic variables}
  44.   OldHeapOrg:=HeapOrg;          {3. Save Current Heap state }
  45.   OldHeapPtr:=HeapPtr;
  46.   HeapOrg:=ptr(OvrHeapOrg,$0);  {4. Set Heap to Origin of Overlay Buffer}
  47.   HeapPtr:=HeapOrg;
  48.   Mark(Temp);                   {5. Mark the origin of this heap } end;
  49.  
  50. procedure RestoreOverlay; begin
  51.   Release(Temp);                {6. Release all dynamic variables }
  52.   HeapOrg:=OldHeapOrg;          {7. Restore heap pointers }
  53.   HeapPtr:=OldHeapPtr; end;
  54.  
  55. begin
  56.   mark(temp);  {1. Mark the beginning of heap after overlay buffer} end.
  57. end.
  58.  
  59. The unit is to be used before any unit that places items into the heap during
  60. their initialization.  You would call RESTOREHEAP before using the dynamic
  61. variables requiring memory used by the overlay buffer.  A call to OVRCLEARBUF
  62. must come before any call to RESTOREHEAP to ensure that the overlay buffer 
  63. is empty and to force a reload of overlays when you are done.  Note, that all 
  64. dynamic variables residing on the heap, before a RESTOREHEAP call is made, are
  65. lost. (But, you could code around this by manipulating the free list).
  66.  
  67. RESTOREOVERLAY clears the heap again and restores the heap pointers to point
  68. above the overlay buffer.  You may then start using overlaid procedures and
  69. functions again.
  70.  
  71. This is a simple example and may not be suitable for all purposes.
  72.  
  73.  
  74.  
  75.  
  76.